class RMPawn extends UTPawn;

var float ElapsedRegenTime;
var float RegenAmount;
var float RegenTime;
var float BlobIntensity;

event Tick(float DeltaTime)
{
	ElapsedRegenTime += DeltaTime;
	if (ElapsedRegenTime >= RegenTime)
	{
		HealDamage(RegenAmount,Controller, class'DamageType');
		ElapsedRegenTime = 0.0f;
	}
}

event Landed(Vector HitNormal, Actor FloorActor)
{
	//SetPhysics(PHYS_Walking);
}

simulated function bool CalcThirdPersonCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
	local vector CamStart, HitLocation, HitNormal, CamDirX, CamDirY, CamDirZ, CurrentCamOffset;
	local float DesiredCameraZOffset;

	ModifyRotForDebugFreeCam(out_CamRot);

	CamStart = Location;
	CurrentCamOffset = CamOffset;

	if ( bWinnerCam )
	{
		// use "hero" cam
		SetHeroCam(out_CamRot);
		CurrentCamOffset = vect(0,0,0);
		CurrentCamOffset.X = GetCollisionRadius();
	}
	else
	{
		DesiredCameraZOffset = (Health > 0) ? 1.2 * GetCollisionHeight() + Mesh.Translation.Z : 0.f;
		CameraZOffset = (fDeltaTime < 0.2) ? DesiredCameraZOffset * 5 * fDeltaTime + (1 - 5*fDeltaTime) * CameraZOffset : DesiredCameraZOffset;
		if ( Health <= 0 )
		{
			CurrentCamOffset = vect(0,0,0);
			CurrentCamOffset.X = GetCollisionRadius();
		}
	}
	CamStart.Z += CameraZOffset;
	GetAxes(out_CamRot, CamDirX, CamDirY, CamDirZ);
	CamDirX *= CurrentCameraScale;

	if ( (Health <= 0) || bFeigningDeath )
	{
		// adjust camera position to make sure it's not clipping into world
		// @todo fixmesteve.  Note that you can still get clipping if FindSpot fails (happens rarely)
		FindSpot(GetCollisionExtent(),CamStart);
	}
	if (CurrentCameraScale < CameraScale)
	{
		CurrentCameraScale = FMin(CameraScale, CurrentCameraScale + 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
	}
	else if (CurrentCameraScale > CameraScale)
	{
		CurrentCameraScale = FMax(CameraScale, CurrentCameraScale - 5 * FMax(CameraScale - CurrentCameraScale, 0.3)*fDeltaTime);
	}
	if (CamDirX.Z > GetCollisionHeight())
	{
		CamDirX *= square(cos(out_CamRot.Pitch * 0.0000958738)); // 0.0000958738 = 2*PI/65536
	}
	out_CamLoc = CamStart - CamDirX*CurrentCamOffset.X + CurrentCamOffset.Y*CamDirY + CurrentCamOffset.Z*CamDirZ;
	if (Trace(HitLocation, HitNormal, out_CamLoc, CamStart, false, vect(12,12,12)) != None)
	{
		out_CamLoc = HitLocation;
		return false;
	}
	return true;
}

simulated function bool CalcCamera(float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV)
{
	return CalcThirdPersonCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
}

function AddDefaultInventory()
{
	super.AddDefaultInventory();
	InvManager.CreateInventory(class'RedMatter.RMWeap_SpaceTimeGun');
}


defaultproperties
{
	Begin Object Name=WPawnSkeletalMeshComponent
		bOwnerNoSee=false
	End Object
	CustomGravityScaling = 1

	GroundSpeed = 550
	AirSpeed = 550
	RegenAmount = 50
	RegenTime = 1

	CurrentCameraScale=1.0
	CameraScale=9.0
	CameraScaleMin=3.0
	CameraScaleMax=40.0
	CamOffset=(X=10.0,Y=16.0,Z=-13.0)

	Name="Default_RMPawn"
}